using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Voodoo.Pattern;

public class BetterNoAdsSwitcher : MonoBehaviour
{
	public Image _image;

	public Sprite _defaultSprite;

	public Sprite _betterSprite;

	public List<GameObject> _objectsToDeactivate;

	private void OnEnable()
	{
		try
		{
			GameManager instance = SingletonMB<GameManager>.Instance;
			instance.OnBoughtBetterNoAds = (Action)Delegate.Combine(instance.OnBoughtBetterNoAds, new Action(SwitchVisuals));
			SwitchVisuals();
		}
		catch (Exception)
		{
		}
	}

	private void SwitchVisuals()
	{
		_image.sprite = (SingletonMB<GameManager>.Instance.BetterNoAds ? _betterSprite : _defaultSprite);
		if (SingletonMB<GameManager>.Instance.BetterNoAds)
		{
			_image.transform.rotation = Quaternion.identity;
			_objectsToDeactivate.SetActive(isActive: false);
		}
	}

	private void OnDisable()
	{
		try
		{
			GameManager instance = SingletonMB<GameManager>.Instance;
			instance.OnBoughtBetterNoAds = (Action)Delegate.Remove(instance.OnBoughtBetterNoAds, new Action(SwitchVisuals));
		}
		catch (Exception)
		{
		}
	}
}
